import numpy as np

def srs_forward_kinematics(q):
       """
       Calculate the end-effector pose from the joint angles of the robotic arm.
       
       Parameters:
       q : array-like
              1x7 array of joint angles in radians.
       
       Returns:
       res : ndarray
              4x4 homogeneous transformation matrix.
       
       % D-H参数表
        % theta_i(rad) alpha_i(rad) d_i(m) a_i(m)
        %            0        -pi/2    dBS      0
        %            0         pi/2      0      0
        %            0        -pi/2    dSE      0
        %            0         pi/2      0      0
        %            0        -pi/2    dEW      0
        %            0         pi/2      0      0
        %            0            0    dWT      0
       
       """
       
       dBS = 0.404
       dSE = 0.4375
       dEW = 0.4125
       dWT = 0.2755

       T01 = np.array([[np.cos(q[0]), 0, -np.sin(q[0]), 0],
                                   [np.sin(q[0]), 0, np.cos(q[0]), 0],
                                   [0, -1, 0, dBS],
                                   [0, 0, 0, 1]])
       
       T12 = np.array([[np.cos(q[1]), 0, np.sin(q[1]), 0],
                                   [np.sin(q[1]), 0, -np.cos(q[1]), 0],
                                   [0, 1, 0, 0],
                                   [0, 0, 0, 1]])
       
       T23 = np.array([[np.cos(q[2]), 0, -np.sin(q[2]), 0],
                                   [np.sin(q[2]), 0, np.cos(q[2]), 0],
                                   [0, -1, 0, dSE],
                                   [0, 0, 0, 1]])
       
       T34 = np.array([[np.cos(q[3]), 0, np.sin(q[3]), 0],
                                   [np.sin(q[3]), 0, -np.cos(q[3]), 0],
                                   [0, 1, 0, 0],
                                   [0, 0, 0, 1]])
       
       T45 = np.array([[np.cos(q[4]), 0, -np.sin(q[4]), 0],
                                   [np.sin(q[4]), 0, np.cos(q[4]), 0],
                                   [0, -1, 0, dEW],
                                   [0, 0, 0, 1]])
       
       T56 = np.array([[np.cos(q[5]), 0, np.sin(q[5]), 0],
                                   [np.sin(q[5]), 0, -np.cos(q[5]), 0],
                                   [0, 1, 0, 0],
                                   [0, 0, 0, 1]])
       
       T67 = np.array([[np.cos(q[6]), -np.sin(q[6]), 0, 0],
                                   [np.sin(q[6]), np.cos(q[6]), 0, 0],
                                   [0, 0, 1, dWT],
                                   [0, 0, 0, 1]])
       
       res = T01 @ T12 @ T23 @ T34 @ T45 @ T56 @ T67
       
       return res